import {commLayer} from "@/view/Home/map/maptools/MapSource";

/**
 * 生成地图工具菜单的数据
 */
import i18n from '@/locale'

class MapToolsData {

  constructor() {
    /**
     * 地图类型
     */
    this.mapType=[
      {id:1,name:"WX",desc:'卫星',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:2,name:"YX",desc:'影像',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:3,name:"DX",desc:'地形',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:4,name:"JD",desc:'街道',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:5,name:"SL",desc:'矢量',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:6,name:"vec",desc:'标准',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:7,name:"gray",desc:'灰色',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:8,name:"blue",desc:'蓝色',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:9,name:"warm",desc:'暖色',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:10,name:"china",desc:'中国',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:11,name:"Hydro",desc:'水系',disabled:false,visible:false,divided:false,selected:false,source:null},
      {id:12,name:"green",desc:'植被',disabled:false,visible:false,divided:false,selected:false,source:null},
    ];

    /**
     * 地图源
     */
    this.customMaps=[
      {id:4,name:'GaoDe',desc:i18n.t('map_ven_gaode'),minZoom:3,maxZoom:18,disabled:false,selected:false,coordinateType:'GCJ02',projection:"EPSG:4326",
        sub:[
          {id:1,name:'GaoDeJD',desc:i18n.t('map_type_street'),type:"JD",disabled:false,selected:true,divided:false,
            url:[
              document.location.protocol+'//webrd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}'
            ]
          },
          {id:2,name:'GaoDeYX',desc:i18n.t('map_type_image'),type:"YX",disabled:false,selected:false,divided:false,
            url:[
              document.location.protocol+'//wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=6',
              document.location.protocol+'//wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=8'
            ]
          },
          {id:3,name:'GaoDeSL',desc:i18n.t('map_type_vector'),type:"SL",disabled:false,selected:false,divided:false,
            url:[
              document.location.protocol+'//wprd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=7'
            ]
          },
        ]
      },
/*
      {id:1,name:'GEOQ',desc:'智图',minZoom:3,maxZoom:18,disabled:true,selected:false,coordinateType:'WGS84',
        sub:[
          {id:1,name:'GEOQvec',desc:'标准',type:"vec",disabled:false,selected:false,divided:false,
            url:['http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}']
          },
          {id:2,name:'GEOQgray',desc:'灰色',type:"gray",disabled:false,selected:false,divided:false,
            url:['http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer/tile/{z}/{y}/{x}']
          },
          {id:3,name:'GEOQblue',desc:'蓝色',type:"blue",disabled:false,selected:false,divided:false,
            url:['http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}']
          },
          {id:4,name:'GEOQwarm',desc:'暖色',type:"warm",disabled:false,selected:false,divided:false,
            url:['http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer/tile/{z}/{y}/{x}']
          },
          {id:5,name:'GEOQchina',desc:'中国',type:"china",disabled:false,selected:false,divided:false,
            url:['http://thematic.geoq.cn/arcgis/rest/services/ThematicMaps/administrative_division_boundaryandlabel/MapServer/tile/{z}/{y}/{x}']
          },
          {id:6,name:'GEOQHydro',desc:'水系',type:"Hydro",disabled:false,selected:false,divided:false,
            url:['http://thematic.geoq.cn/arcgis/rest/services/ThematicMaps/WorldHydroMap/MapServer/tile/{z}/{y}/{x}']
          },
          {id:7,name:'GEOQgreen',desc:'植被',type:"green",disabled:false,selected:false,divided:false,
            url:['http://thematic.geoq.cn/arcgis/rest/services/ThematicMaps/vegetation/MapServer/tile/{z}/{y}/{x}']
          },
        ]
      },
      {id:2,name:'Baidu',desc:'百度地图',minZoom:3,maxZoom:18,disabled:true,selected:false,divided:true,coordinateType:'BD09'},
      {id:3,name:'TianDi',desc:'天地图',minZoom:3,maxZoom:18,disabled:true,selected:false,divided:true,coordinateType:'WGS84',
        sub:[
          {id:1,name:'TianDiJD',desc:'街道',type:"JD",disabled:false,selected:false,divided:false,
            url:[
              'http://t{0-7}.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=7786923a385369346d56b966bb6ad62f',
              'http://t{0-7}.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=7786923a385369346d56b966bb6ad62f'
            ]
          },
          {id:2,name:'TianDiWX',desc:'卫星',type:"WX",disabled:false,selected:false,divided:false,
            url:[
              'http://t{0-7}.tianditu.com/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=7786923a385369346d56b966bb6ad62f',
              'http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=7786923a385369346d56b966bb6ad62f'
            ]
          },
          {id:3,name:'TianDiDX',desc:'地形',type:"DX",disabled:false,selected:false,divided:false,
            url:['http://t{0-7}.tianditu.com/DataServer?T=ter_w&x={x}&y={y}&l={z}&tk=7786923a385369346d56b966bb6ad62f',
              'http://t{0-7}.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=7786923a385369346d56b966bb6ad62f'
            ]
          },
        ]
      },
      */


      {id:5,name:'Google',desc:i18n.t('map_ven_google'),minZoom:3,maxZoom:21,disabled:false,selected:false,coordinateType:'GCJ02',projection:"EPSG:3857",
        sub:[
          {id:1,name:'GoogleJD',desc:i18n.t('map_type_street'),type:"JD",disabled:false,selected:false,divided:false,
            url:[
              document.location.protocol+'//www.google.com/maps/vt?lyrs=m@189&gl=cn&x={x}&y={y}&z={z}'
            ]
          },
          {id:2,name:'GoogleYX',desc:i18n.t('map_type_image'),type:"YX",disabled:false,selected:false,divided:false,
            url:[
              document.location.protocol+'//www.google.com/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}'
            ]
          },
        ]
      },
      /*
      {id:6,name:'Arcgis',desc:'ArcGis',minZoom:3,maxZoom:18,disabled:true,selected:false,coordinateType:'WGS84',
        sub:[
          {id:1,name:'ArcgisJD',desc:'街道',type:"JD",disabled:false,selected:false,divided:false,
            url:[
              'http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}'
            ]
          },
          {id:2,name:'ArcgisYX',desc:'影像',type:"YX",disabled:false,selected:false,divided:false,
            url:[
              'https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
            ]
          },
        ]
      },
      {id:7,name:'OSM',desc:'OSM',minZoom:3,maxZoom:18,disabled:true,selected:false,divided:false,coordinateType:'WGS84'},

 */
      //{name:'BingMaps',desc:'必应地图'},
    ];

    /**
     * 地图工具
     */
    this.drawTools=[
      {id:1,name:'LINE',desc:i18n.t('map_tool_straight_line'),disabled:false,selected:false},
      {id:2,name:'POLYGON',desc:i18n.t('polygon'),disabled:false,selected:false},
      {id:3,name:'CIRCLE',desc:i18n.t('circle'),disabled:false,selected:false},
      {id:4,name:'DISTANCE',desc:i18n.t('map_tool_ranging'),disabled:false,selected:false},

    ]

  }
  //初始化
  _init(){
  }

  /**
   *  地图类型
   * @returns
   */
  getMapType(){
    return this.mapType;
  }

  /**
   * 地图 资源
   *
   */
  getMapSource(){
    return this.customMaps;
  }

  /**
   * 地图工具
   * @returns
   */
  getDrawTools(){
    return this.drawTools;
  }

  /**
   * 由采集名称取得菜单项
   */
  getCustomMap(name){
    for(let i=0;i<this.customMaps.length;i++){
      if (this.customMaps[i].name === name){
        return this.customMaps[i];
      }
    }
  }

  /**
   * 取得地图的坐标系
   *
   */
  getCoordinateType(name){
    for(let i in this.customMaps){
      if (this.customMaps[i].name == name){
        return this.customMaps[i].coordinateType;
        break;
      }
    }
    return 'WGS84';
  }

}

export default MapToolsData;
